package com.neu.elm.mapper;

import com.neu.elm.po.Orders;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;

import java.util.List;

/**
 * @Author:csw
 * @Date: 14:26 2020/9/15
 */
@Mapper
public interface OrdersMapper {
    //保存订单，设置useGeneratedKeys为true，返回数据库自动生成的记录主键ID
    @Insert("insert into orders(userId,businessId,orderDate,orderTotal,daId,orderState) values(#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},0)")
    @Options(useGeneratedKeys = true,keyProperty = "orderId",keyColumn = "orderId")
    public int saveOrders(Orders orders);

    //按订单主键获取单体订单
    public Orders getOrdersById(Integer orderId);

    //按用户的ID获取订单集合
    public List<Orders> listOrdersByUserId(String userId);

}
